home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
prog
/
atari
/
m2
/
cat3src
/
cat
/
plisthel.i
< prev
next >
Wrap
Text File
|
1997-10-26
|
21KB
|
689 lines
IMPLEMENTATION MODULE PListHelp;
(*==============================================================*
* Modul: Modul zur Verwaltung der Abrufboxen *
* Autor: Dirk Steins *
* erstellt am: 16.10.1993 *
* letzte nderung am: 16.10.1993 *
* Version: 1.0 *
* Interne Version: V#0001 *
*==============================================================*
*----------------------------------------------------------------------------
* Datum Vers. Autor nderung (Arbeitsbericht)
*----------------------------------------------------------------------------
*----------------------------------------------------------------------------
*)
FROM SYSTEM IMPORT ADDRESS, TSIZE, ADR, CADR, CAST;
FROM Storage IMPORT ALLOCATE, DEALLOCATE;
IMPORT Lists;
IMPORT PathCtrl;
IMPORT Strings;
IMPORT GrafBase;
IMPORT BinOps;
IMPORT ShellMsg;
FROM Void IMPORT v;
FROM ListDl IMPORT WinListDial, specialButHdler, dummyInLoop, inLoopProc,
BuildLdHandler, ldHandler, ldElems, ldElemSet, dummyCheckExit;
IMPORT CatTypes;
IMPORT ListMan;
IMPORT CatGlobal;
IMPORT ConfVars;
IMPORT Varnames;
IMPORT MTE;
IMPORT EditFuncs;
IMPORT CatFiles;
IMPORT AssFuncs;
IMPORT Fredrsc;
IMPORT MagicAES;
IMPORT MagicDOS;
IMPORT MagicStrings;
IMPORT MagicTypes;
IMPORT MagicSys;
IMPORT mtAppl;
IMPORT mtDials;
IMPORT mtAlerts;
IMPORT mtUtils;
VAR pathBox : ADDRESS;
globalLength : INTEGER;
TYPE pathEntry = RECORD
entry: PathCtrl.PathEntry;
selected : BOOLEAN;
END;
pathPtr = POINTER TO pathEntry;
(*------------------------------------------------------------------------*)
PROCEDURE nextEntry ( l : ADDRESS) : ADDRESS;
VAR lp : POINTER TO Lists.List;
BEGIN
lp := l;
RETURN Lists.NextEntry (lp^);
END nextEntry;
PROCEDURE prevEntry ( l : ADDRESS) : ADDRESS;
VAR lp : POINTER TO Lists.List;
BEGIN
lp := l;
RETURN Lists.PrevEntry (lp^)
END prevEntry;
PROCEDURE countEntries ( l : ADDRESS; VAR ll: LONGINT; VAR ww: INTEGER);
VAR lp : POINTER TO Lists.List;
BEGIN
lp := l;
ww := globalLength*mtAppl.CharWidth;
ll := VAL (LONGINT, Lists.NoOfEntries (lp^));
END countEntries;
PROCEDURE resetList (l : ADDRESS);
VAR lp : POINTER TO Lists.List;
BEGIN
lp := l;
Lists.ResetList (lp^);
END resetList;
PROCEDURE isEnabled (adr : ADDRESS; env : ADDRESS) : BOOLEAN;
BEGIN
RETURN TRUE
END isEnabled;
(*------------------------------------------------------------------------*)
VAR pathList : Lists.List;
clipEntry : pathPtr;
PROCEDURE selGrEntry (entry, env : ADDRESS; line : INTEGER): BOOLEAN;
VAR gr : pathPtr;
str: CatTypes.String255;
BEGIN
gr := entry;
IF gr = NIL THEN RETURN FALSE END;
gr^.selected := ~gr^.selected;
RETURN FALSE
END selGrEntry;
PROCEDURE groupToStr (entry, env : ADDRESS; VAR str : ARRAY OF CHAR);
VAR gr : pathPtr;
BEGIN
gr := entry;
IF gr = NIL THEN RETURN END;
MagicStrings.Assign (gr^.entry^,str);
globalLength := BinOps.HigherInt (globalLength, LENGTH (str)+2);
END groupToStr;
(*$Z-*)
PROCEDURE findSel (e, i : ADDRESS): BOOLEAN;
VAR entry : pathPtr;
BEGIN
entry := e;
RETURN entry^.selected;
END findSel;
PROCEDURE findName (e, i : ADDRESS): BOOLEAN;
VAR entry : pathPtr;
str : CatTypes.Str255Ptr;
BEGIN
entry := e;
str := i;
RETURN AssFuncs.StrIequal (entry^.entry^, str^);
END findName;
(*$Z=*)
PROCEDURE cutEntry (obj: INTEGER; env, info : ADDRESS; VAR draw : BOOLEAN; VAR exit : BOOLEAN);
VAR r : GrafBase.Rectangle;
found : BOOLEAN;
listInfo : ListMan.LISTINFO;
BEGIN
(* Selektierten Eintrag in der Liste finden und aus der Liste entfernen *)
Lists.ResetList (pathList);
Lists.ScanEntries (pathList, Lists.forward, findSel, NIL, found);
IF found THEN
IF clipEntry # NIL
THEN
(* Alten Eintrag lschen *)
DEALLOCATE (clipEntry^.entry, 0);
DEALLOCATE (clipEntry, 0);
END;
clipEntry := Lists.CurrentEntry (pathList);
Lists.RemoveEntry (pathList, v.bool);
listInfo := ListMan.LISTINFO (info);
ListMan.ListScroll2Selection (listInfo, TRUE);
(* Nun das neue Icon darstellen *)
mtUtils.SetFlag (pathBox, Fredrsc.Pclfull, MagicAES.HIDETREE, FALSE);
mtUtils.SetFlag (pathBox, Fredrsc.Pclempty, MagicAES.HIDETREE, TRUE);
mtUtils.CalcArea (pathBox, Fredrsc.Pclfull, r);
mtDials.DialDraw (pathBox, 0, 8, r, TRUE);
END;
mtUtils.SetState (pathBox, obj, MagicAES.SELECTED, FALSE);
mtDials.DialDraw (pathBox, obj, 1, v.r, FALSE);
draw := found;
exit := FALSE;
END cutEntry;
PROCEDURE pasteEntry (obj: INTEGER; env, info: ADDRESS; VAR draw : BOOLEAN; VAR exit : BOOLEAN);
VAR r : GrafBase.Rectangle;
r1, r2 : GrafBase.Rectangle;
x, y : INTEGER;
kstate,
buts : BITSET;
found : BOOLEAN;
index : LONGINT;
adr : pathPtr;
listInfo : ListMan.LISTINFO;
BEGIN
exit := FALSE;
IF clipEntry = NIL
THEN
draw := FALSE;
RETURN
END;
mtUtils.ObjcArea (pathBox, Fredrsc.Pclfull, r1);
mtUtils.ObjcArea (pathBox, 0, r2);
MagicAES.GrafMkstate (x, y, buts, kstate);
IF (0 IN buts)
THEN
listInfo := ListMan.LISTINFO (info);
MagicAES.GrafDragbox (r1, r2, x, y);
MagicAES.GrafMkstate (x, y, buts, kstate);
index := ListMan.ListClick (listInfo, x, y, kstate, 0);
(* Persnliche bleiben immer vorne: *)
IF index = 0 THEN INC (index) END;
IF index > 0
THEN
adr := ListMan.ListFindEntry (listInfo, index);
IF adr = NIL
THEN
Lists.AppendEntry (pathList, clipEntry, v.bool);
index := LONG(Lists.NoOfEntries (pathList));
ELSE
IF index > 1 THEN adr := Lists.PrevEntry (pathList); END;
Lists.InsertEntry (pathList, clipEntry, v.bool);
END;
(* Jetzt mal schnell alle Eintrge deselektieren *)
Lists.ResetList (pathList);
adr := Lists.NextEntry (pathList);
WHILE adr # NIL DO
adr^.selected := FALSE;
adr := Lists.NextEntry (pathList);
END;
clipEntry^.selected := FALSE;
v.bool := selGrEntry (clipEntry, env, 0);
ListMan.ListScroll2Selection (listInfo, TRUE);
mtUtils.SetFlag (pathBox, Fredrsc.Pclfull, MagicAES.HIDETREE, TRUE);
mtUtils.SetFlag (pathBox, Fredrsc.Pclempty, MagicAES.HIDETREE, FALSE);
mtUtils.CalcArea (pathBox, Fredrsc.Pclempty, r);
mtDials.DialDraw (pathBox, 0, 8, r, TRUE);
clipEntry := NIL;
draw := TRUE;
ELSE
draw := FALSE;
END;
ELSE
draw := FALSE;
END;
END pasteEntry;
PROCEDURE clipEmpty (obj: INTEGER; env, info : ADDRESS; VAR draw : BOOLEAN; VAR exit : BOOLEAN);
CONST
clipInfo = "[1][FRED:|Dieses Klemmbrett enthlt den zuletzt|von Ihnen gelschten Pfad. Momentan|";
clipInfo2 = "knnen Sie es nicht benutzen,|da es leer ist.][[Ok]";
BEGIN
MTE.InfoAlert (clipInfo, clipInfo2, "");
draw := FALSE;
exit := FALSE;
END clipEmpty;
PROCEDURE updateButton (entry, env : ADDRESS);
VAR oneSel : BOOLEAN;
gr : pathPtr;
BEGIN
Lists.ResetList (pathList);
Lists.ScanEntries (pathList, Lists.forward, findSel, NIL, oneSel);
IF oneSel
THEN
gr := Lists.CurrentEntry (pathList);
END;
IF (oneSel & mtUtils.InState (pathBox, Fredrsc.Pdelete, MagicAES.DISABLED))
OR (~oneSel & ~mtUtils.InState (pathBox, Fredrsc.Pdelete, MagicAES.DISABLED))
THEN
mtUtils.SetState (pathBox, Fredrsc.Pdelete, MagicAES.DISABLED, ~oneSel);
mtDials.DialDraw (pathBox, Fredrsc.Pdelete, 0, v.r, FALSE);
mtUtils.SetState (pathBox, Fredrsc.Pchange, MagicAES.DISABLED, ~oneSel);
mtDials.DialDraw (pathBox, Fredrsc.Pchange, 0, v.r, FALSE);
END;
END updateButton;
PROCEDURE EnvSearch (VAR val : ARRAY OF CHAR; REF name: ARRAY OF CHAR;
env : ADDRESS);
PROCEDURE search (str, name : ARRAY OF CHAR;
VAR val : ARRAY OF CHAR) : BOOLEAN;
VAR i : INTEGER;
BEGIN
Strings.Append ('=',name,v.bool);
i := Strings.Pos (name, str, 0);
IF i < 0 THEN RETURN FALSE END;
Strings.Copy (str, i+INTEGER(Strings.Length(name)),
INTEGER(Strings.Length (str)-Strings.Length(name))-i, val, v.bool);
RETURN TRUE
END search;
VAR ch : POINTER TO CHAR;
lastCh : CHAR;
i : INTEGER;
str : ARRAY [0..2047] OF CHAR;
BEGIN
ch := env;
lastCh := ch^;
i := 0;
(* Solange noch env da ist *)
WHILE (ch^ # 0C) OR (lastCh # 0C) DO
str[i] := ch^;
INC(i);
lastCh := ch^;
IF lastCh = 0C
THEN (* string complete, search *)
IF search(str, name, val) THEN RETURN
ELSE
str := "";
i := 0;
END;
END;
INC (ch);
END;
END EnvSearch;
PROCEDURE getSystemPaths (obj: INTEGER; env, info: ADDRESS; VAR draw, exit: BOOLEAN);
VAR basePage : MagicTypes.PtrPD;
systemPath : ARRAY [0..2047] OF CHAR;
p, p1, p2 : INTEGER;
path : CatTypes.String255;
new : pathPtr;
ok : BOOLEAN;
BEGIN
draw := FALSE;
(* suchen nach Environment-Variable PATH *)
basePage := MagicSys.Basepage();
systemPath[0] := '';
EnvSearch (systemPath, 'PATH', basePage^.pEnv);
IF systemPath[0] # ''
THEN
IF (systemPath[0] = ',')
OR (systemPath[0] = ';')
THEN
p := 1;
ELSE
p := 0;
END;
REPEAT
p1 := Strings.Pos (',', systemPath, p);
p2 := Strings.Pos (';', systemPath, p);
IF (p1 > 0) OR (p2 > 0)
THEN
IF (p1 > 0) & ((p1 < p2) OR (p2 < 0))
THEN
(* Komma als Trenner gefunden *)
Strings.Copy (systemPath, p, p1-p, path, v.bool);
p := p1+1;
ELSIF (p2 > 0) & ((p2 < p1) OR (p1 < 0))
THEN
(* Semikolon als Trenner gefunden *)
Strings.Copy (systemPath, p, p2-p, path, v.bool);
p := p2+1;
END;
(* Erstmal nachsehen, ob der Pfad eh schon drin ist *)
Lists.ResetList (pathList);
Lists.ScanEntries (pathList, Lists.forward, findName, ADR(path), ok);
IF ~ok
THEN
(* Jetzt neuen Eintrag fr die Liste erzeugen *)
NEW (new);
IF new # NIL
THEN
ALLOCATE (new^.entry, LENGTH (path)+2);
IF new^.entry # NIL
THEN
MagicStrings.Assign (path, new^.entry^);
globalLength := BinOps.HigherInt (globalLength, LENGTH (path)+2);
new^.selected := FALSE;
(* Neuen Eintrag anlegen *)
Lists.AppendEntry (pathList, new, v.bool);
draw := TRUE;
ELSE
DISPOSE (new);
END;
END;
END;
ELSE
p := -1;
END;
UNTIL p < 0;
END;
exit := FALSE;
mtUtils.ExclState (pathBox, obj, MagicAES.SELECTED);
mtDials.DialDraw (pathBox, obj, 1, v.r, FALSE);
END getSystemPaths;
PROCEDURE changeGroup (obj: INTEGER; env, info: ADDRESS; VAR draw, exit: BOOLEAN);
CONST cTitel = 'Pfad auswhlen';
VAR wegen: ADDRESS;
cPath : CatTypes.String255;
name : CatTypes.String127;
oneSel: BOOLEAN;
but : INTEGER;
ok : BOOLEAN;
gr : pathPtr;
new : pathPtr;
path : ADDRESS;
BEGIN
draw := FALSE;
Lists.ResetList (pathList);
Lists.ScanEntries (pathList, Lists.forward, findSel, NIL, oneSel);
IF oneSel
THEN
gr := Lists.CurrentEntry (pathList);
MagicStrings.Assign (gr^.entry^, cPath);
ELSE
CatFiles.GetPath (cPath);
END;
MagicStrings.Assign ('', name);
IF CatGlobal.FselGet(cPath, name, '*.*', cTitel, TRUE)
THEN
(* Mal nachsehen, ob der Pfad schon da ist *)
Lists.ResetList (pathList);
Lists.ScanEntries (pathList, Lists.forward, findName, ADR(cPath), ok);
IF ok
THEN
IF ((obj = Fredrsc.Pchange) & (gr # Lists.CurrentEntry (pathList)))
OR (obj = Fredrsc.Pnew)
THEN
MTE.info ('[3][FRED:|Der Pfad ist schon|in der Pfadliste!][[Abbruch]');
END;
END;
IF ~ok (* nicht vorhanden in Liste *)
THEN
(* Neuen Eintrag erzeugen *)
ALLOCATE (path, LENGTH (cPath) + 2);
IF path # NIL
THEN
NEW (new);
IF new # NIL
THEN
new^.entry := path;
MagicStrings.Assign (cPath, new^.entry^);
globalLength := BinOps.HigherInt (globalLength, LENGTH (cPath)+2);
new^.selected := FALSE;
(* Jetzt nach Objekt unterscheiden *)
IF obj = Fredrsc.Pnew
THEN
(* Neuen Eintrag anlegen *)
Lists.AppendEntry (pathList, new, v.bool);
ELSE
(* vorhandenen Eintrag suchen und ersetzen *)
Lists.ResetList (pathList);
Lists.ScanEntries (pathList, Lists.forward, findSel, NIL, oneSel);
gr := Lists.CurrentEntry (pathList);
Lists.RemoveEntry (pathList, v.bool);
DEALLOCATE (gr^.entry, 0);
DEALLOCATE (gr, 0);
Lists.InsertEntry (pathList, new, v.bool);
END;
draw := TRUE;
ELSE
DEALLOCATE (path, 0);
EditFuncs.OutOfMem();
END;
ELSE
EditFuncs.OutOfMem();
END;
END; (* IF nicht in Liste *)
END; (* IF FselGet *)
mtUtils.ExclState (pathBox, obj, MagicAES.SELECTED);
mtDials.DialDraw (pathBox, obj, 1, v.r, FALSE);
exit := FALSE;
END changeGroup;
(* List-Zwischen-Prozeduren *)
PROCEDURE groupIsSelected (entry, env : ADDRESS) : BOOLEAN;
VAR ent : pathPtr;
BEGIN
ent := entry;
RETURN ent^.selected;
END groupIsSelected;
VAR tr : mtUtils.tObjcTree;
PROCEDURE drawGroupEntry (entry, env : ADDRESS; x, y : INTEGER;
offset : INTEGER; clip : GrafBase.Rectangle);
CONST spaceString = " ";
VAR e : pathPtr;
str : CatTypes.String255;
BEGIN
e := entry;
tr^[0].obX := x;
tr^[0].obY := y;
tr^[0].obSpec.TedPtr^.teTxtlen := globalLength;
tr^[0].obWidth := globalLength*mtAppl.CharWidth;
IF e # NIL
THEN
(* Jetzt hier den String fr den Gruppennamen zusammenbauen *)
groupToStr (e, env, str);
mtUtils.SetObjcStringAdr (tr, 0, ADR(str));
mtUtils.SetState (tr, 0, MagicAES.SELECTED, groupIsSelected (entry, env));
mtUtils.SetState (tr, 0, MagicAES.DISABLED, ~isEnabled (entry, env));
ELSE
mtUtils.SetObjcStringAdr (tr, 0, CADR(spaceString));
mtUtils.SetState (tr, 0, MagicAES.SELECTED, FALSE);
mtUtils.SetState (tr, 0, MagicAES.DISABLED, FALSE);
END;
MagicAES.ObjcDraw (tr, 0, 8, clip);
END drawGroupEntry;
PROCEDURE killPathList();
VAR entry : pathPtr;
BEGIN
Lists.ResetList (pathList);
entry := Lists.NextEntry (pathList);
WHILE entry # NIL DO
Lists.RemoveEntry (pathList, v.bool);
DEALLOCATE (entry^.entry, 0);
DEALLOCATE (entry, 0);
entry := Lists.NextEntry (pathList);
END;
Lists.DeleteList (pathList, v.bool);
END killPathList;
PROCEDURE setAndGetPathValues (tree: ADDRESS; private: ADDRESS; set: BOOLEAN; exitBut: INTEGER);
VAR iPtr : POINTER TO INTEGER;
BEGIN
IF set
THEN
ELSE
iPtr := private;
iPtr^ := exitBut;
END;
END setAndGetPathValues;
(* Pfadeinstellungen vornehmen *)
PROCEDURE SelectPaths (tree: ADDRESS);
VAR exit : INTEGER;
VAR specials : ARRAY [0..5] OF specialButHdler;
gr,
group : pathPtr;
found : BOOLEAN;
GroupOk : BOOLEAN;
maxLength: INTEGER;
r : GrafBase.Rectangle;
ilProc : inLoopProc;
whichList: BOOLEAN;
entry : CatTypes.Str255Ptr;
succ : BOOLEAN;
pathHandler: ldHandler;
BEGIN
pathBox := tree;
mtUtils.SetFlag (pathBox, Fredrsc.Pclfull, MagicAES.HIDETREE, TRUE);
mtUtils.SetFlag (pathBox, Fredrsc.Pclempty, MagicAES.HIDETREE, FALSE);
found := FALSE;
(* specials bestimmen *)
specials[0].objc := Fredrsc.Pdelete;
specials[0].proc := cutEntry;
specials[1].objc := Fredrsc.Pclfull;
specials[1].proc := pasteEntry;
specials[2].objc := Fredrsc.Pclempty;
specials[2].proc := clipEmpty;
specials[3].objc := Fredrsc.Pnew;
specials[3].proc := changeGroup;
specials[4].objc := Fredrsc.Pchange;
specials[4].proc := changeGroup;
specials[5].objc := Fredrsc.Ppath;
specials[5].proc := getSystemPaths;
IF clipEntry # NIL
THEN
(* Alten Eintrag lschen *)
DEALLOCATE (clipEntry^.entry, 0);
DEALLOCATE (clipEntry, 0);
END;
clipEntry := NIL;
ilProc := updateButton;
(* Jetzt die Liste aufbauen *)
Lists.ResetList (ShellMsg.SrcPaths);
entry := Lists.NextEntry (ShellMsg.SrcPaths);
Lists.CreateList (pathList, succ);
IF succ
THEN
mtDials.DisposeDial (pathBox);
EditFuncs.OutOfMem();
RETURN
END;
succ := TRUE;
WHILE (entry # NIL) & succ DO
NEW (group);
IF group = NIL
THEN
succ := FALSE;
ELSE
ALLOCATE (group^.entry, LENGTH (entry^)+2);
IF group^.entry = NIL
THEN
succ := FALSE;
ELSE
MagicStrings.Assign (entry^, group^.entry^);
group^.selected := FALSE;
Lists.AppendEntry (pathList, group, v.bool);
succ := ~v.bool;
END;
END;
entry := Lists.NextEntry (ShellMsg.SrcPaths);
END;
IF ~succ THEN
killPathList();
mtDials.DisposeDial (pathBox);
EditFuncs.OutOfMem();
RETURN
END;
(* Maximale Breite eines Listeneintrages herausfinden *)
maxLength := 0;
Lists.ResetList (pathList);
group := Lists.NextEntry (pathList);
WHILE group # NIL DO
IF INTEGER(LENGTH (group^.entry^)) > maxLength
THEN
maxLength := LENGTH (group^.entry^);
END;
group := Lists.NextEntry (pathList);
END;
INC (maxLength); (* damit es besser aussieht :-) *)
(* Jetzt das Object zusammenbauen *)
mtUtils.CalcArea (pathBox, Fredrsc.Pathbox, r);
maxLength := BinOps.HigherInt (maxLength, r.w DIV mtAppl.CharWidth);
globalLength := maxLength;
(* Objectadresse holen *)
tr := MagicAES.RsrcGaddr (MagicAES.RTREE, Fredrsc.Listtxt);
(* Handler bauen *)
BuildLdHandler (ADR(pathList), resetList, nextEntry, prevEntry,
countEntries, isEnabled, selGrEntry,
groupToStr, groupIsSelected, drawGroupEntry,
0, mtAppl.CharHeight,
8, maxLength*mtAppl.CharWidth,
pathHandler);
(* ListDialog durchfhren *)
IF WinListDial (pathBox, ldElemSet{ldSelect, ldArrows, ldDoubleExit, ldModal},
pathHandler,
Fredrsc.Pathbox,
Fredrsc.Pathback,
Fredrsc.Pok,
Fredrsc.Pcancel,
ADR(exit), Fredrsc.Pok,
-1,
ilProc,
specials,
6,
dummyCheckExit,
setAndGetPathValues,
setAndGetPathValues,
group)
THEN
IF exit = Fredrsc.Pok THEN
(* Vernderte Pfadliste speichern *)
(* Erstmal die alte lschen *)
Lists.ResetList (ShellMsg.SrcPaths);
entry := Lists.NextEntry (ShellMsg.SrcPaths);
WHILE entry # NIL DO
Lists.RemoveEntry (ShellMsg.SrcPaths, v.bool);
(* DEALLOCATE (entry, 0); *)
entry := Lists.NextEntry (ShellMsg.SrcPaths);
END;
Lists.ResetList (ShellMsg.SrcPaths);
Lists.ResetList (pathList);
group := Lists.NextEntry (pathList);
succ := TRUE;
WHILE (group # NIL) & succ DO
entry := NIL;
ALLOCATE (entry, LENGTH (group^.entry^)+2);
IF entry = NIL
THEN
succ := FALSE;
ELSE
MagicStrings.Assign (group^.entry^, entry^);
Lists.AppendEntry (ShellMsg.SrcPaths, entry, v.bool);
succ := ~v.bool;
END;
group := Lists.NextEntry (pathList);
END;
IF ~succ THEN
EditFuncs.OutOfMem();
END;
END;
END;
(* Interne Pfadliste wieder freigeben *)
killPathList();
END SelectPaths;
BEGIN
clipEntry := NIL;
END PListHelp.